package com.meitianhui.convenitenbuy.module.mine.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meitianhui.convenitenbuy.R;
import com.meitianhui.convenitenbuy.module.store.model.StoreInfo;

import java.util.List;

/**
 * Created by amy on 2017/11/28.
 */

public class SearchGuiderStoreAdapter extends BaseQuickAdapter<StoreInfo.Convenient,BaseViewHolder> {
    public SearchGuiderStoreAdapter(@Nullable List<StoreInfo.Convenient> data) {
        super(R.layout.item_shop_guider, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, StoreInfo.Convenient item) {
        helper.getView(R.id.tv_item_guider_unbind).setVisibility(View.GONE);
        helper.getView(R.id.tv_item_guider_bind).setVisibility(View.VISIBLE);
        helper.setText(R.id.tv_item_guider_name, item.getStores_name());
        helper.setText(R.id.tv_item_guider_phone, item.getContact_tel());
        helper.setText(R.id.tv_item_guider_address, item.getAddress());

        helper.getView(R.id.tv_item_guider_bind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnClickButtonListener != null){
                    mOnClickButtonListener.clickBindOrUnbind(helper.getPosition());
                }
            }
        });

    }

    public interface OnClickButtonListener {
        void clickBindOrUnbind(int position);
    }

    private OnClickButtonListener mOnClickButtonListener;

    public void setOnClickButtonListener(OnClickButtonListener listener) {
        this.mOnClickButtonListener = listener;
    }
}
